/*
 * Copyright 2007-2010 kingbi.
 * Creator: Janins
 */
package com.kingbi.system.userRole.service;

import java.util.List;


import com.kingbi.system.userRole.dao.UserRoleDao;
import com.kingbi.system.userRole.dao.UserRoleQuery;
import com.kingbi.system.userRole.model.UserRoleModel;

/**
 * @author mouzb
 * 
 */
public class UserRoleServiceImpl implements UserRoleService
{

	private UserRoleDao userRoleDao;
	public void setUserRoleDao(UserRoleDao thisDao)
    {
        userRoleDao = thisDao;
    }

    public void saveUserRole(UserRoleModel userRoleModel)
    {
	    userRoleDao.save(userRoleModel);

    }
	
	public UserRoleModel loadUserRole(String userRoleID)
    {
        return userRoleDao.findById(userRoleID);
    }
	public void deleteUserRole(String userRoleID)
	{
	    userRoleDao.delete(userRoleDao.findById(userRoleID));
	}

	public List<UserRoleModel> listUserRole(UserRoleModel userRoleModel,int start, int max)
	{
	    UserRoleQuery userRoleQuery = new UserRoleQuery();
	    userRoleQuery.doSearchQuery(userRoleModel);
		return userRoleDao.findByHQL(userRoleQuery.getSearch_query_bud().toString(),userRoleQuery.getParams(), start, max);
	}

	public List<UserRoleModel> loadVerifyUserRole(int page, int max, Object[] sql_params)
	{
		return userRoleDao.findCmd("loadVerifyPack", sql_params, page, max);
	}

    public long queryCount(UserRoleModel userRoleModel)
    {
        UserRoleQuery userRoleQuery = new UserRoleQuery();
        userRoleQuery.doSearchQuery(userRoleModel);
        return userRoleDao.getCountByHQL(userRoleQuery.getSearch_count_bud().toString(), userRoleQuery.getParams());
    }
	
	
}
